package com.huawei.hianalytics.f.h.a;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.text.TextUtils;
import com.huawei.hianalytics.f.g.e;
import com.huawei.hianalytics.f.g.h;
import com.huawei.hianalytics.g.b;
import com.huawei.hianalytics.i.a;
import com.huawei.hms.support.api.entity.hwid.HwIDConstant.ReqAccessTokenParm;
import com.huawei.hwid.core.constants.HwAccountConstants;

public class c implements a {
    private Context a;
    private String b;

    public c(Context context, String str) {
        this.a = context;
        this.b = str;
    }

    private String a(Context context) {
        return e.a(context, "cached");
    }

    private String a(SharedPreferences sharedPreferences, String str) {
        return (String) h.b(sharedPreferences, str, "");
    }

    private void a(Context context, String str) {
        Editor edit = h.d(context, str).edit();
        edit.clear();
        edit.apply();
    }

    private void a(b bVar, String str, String str2) {
        bVar.a(str, this.b);
        bVar.b(str2, this.b);
        bVar.a(this.b);
    }

    private void a(String str, String str2, String str3) {
        a(new d(), str, str3);
        a(new e(), str2, str3);
    }

    private void b(Context context) {
        a(context, ReqAccessTokenParm.STATE_LABEL);
        a(context, "sessioncontext");
        a(context, HwAccountConstants.TRUSTCIRCLE_VERIFY_REQUEST_KEY_SCREENPWD_FLAG);
        c(context);
    }

    private void c(Context context) {
        e.b(context, "cached");
    }

    public void a() {
        SharedPreferences d = h.d(this.a, ReqAccessTokenParm.STATE_LABEL);
        if (d == null) {
            b.b("V1CompatibleReportTask", "checkAndReportV1Data: get sharedPreference error.");
            return;
        }
        String a = a(d, "events");
        String a2 = a(d, "activities");
        String a3 = a(this.a);
        b(this.a);
        if (TextUtils.isEmpty(a) && TextUtils.isEmpty(a2) && TextUtils.isEmpty(a3)) {
            b.b("V1CompatibleReportTask", "checkAndReportV1Data: No cached V1 data found.");
        } else {
            a(a, a2, a3);
        }
    }

    public void run() {
        a();
    }
}
